home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / sftgrd / softgrid.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-06-12  |  23.9 KB  |  683 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   8340
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   7365
  8.    Height          =   8745
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   8340
  12.    ScaleWidth      =   7365
  13.    Top             =   1140
  14.    Width           =   7485
  15.    Begin ListBox GridLst 
  16.       Height          =   5295
  17.       Left            =   120
  18.       TabIndex        =   0
  19.       Top             =   1920
  20.       Width           =   6735
  21.    End
  22.    Begin Label GridLblTitles 
  23.       Alignment       =   2  'Center
  24.       BackColor       =   &H00C0C0C0&
  25.       BorderStyle     =   1  'Fixed Single
  26.       Caption         =   "GridLblTitles"
  27.       Height          =   255
  28.       Index           =   11
  29.       Left            =   5520
  30.       TabIndex        =   12
  31.       Top             =   1080
  32.       Width           =   1095
  33.    End
  34.    Begin Label GridLblTitles 
  35.       Alignment       =   2  'Center
  36.       BackColor       =   &H00C0C0C0&
  37.       BorderStyle     =   1  'Fixed Single
  38.       Caption         =   "GridLblTitles"
  39.       Height          =   255
  40.       Index           =   10
  41.       Left            =   4440
  42.       TabIndex        =   11
  43.       Top             =   1080
  44.       Width           =   1095
  45.    End
  46.    Begin Label GridLblTitles 
  47.       Alignment       =   2  'Center
  48.       BackColor       =   &H00C0C0C0&
  49.       BorderStyle     =   1  'Fixed Single
  50.       Caption         =   "GridLblTitles"
  51.       Height          =   255
  52.       Index           =   9
  53.       Left            =   3360
  54.       TabIndex        =   10
  55.       Top             =   1080
  56.       Width           =   1095
  57.    End
  58.    Begin Label GridLblTitles 
  59.       Alignment       =   2  'Center
  60.       BackColor       =   &H00C0C0C0&
  61.       BorderStyle     =   1  'Fixed Single
  62.       Caption         =   "GridLblTitles"
  63.       Height          =   255
  64.       Index           =   8
  65.       Left            =   2280
  66.       TabIndex        =   9
  67.       Top             =   1080
  68.       Width           =   1095
  69.    End
  70.    Begin Label GridLblTitles 
  71.       Alignment       =   2  'Center
  72.       BackColor       =   &H00C0C0C0&
  73.       BorderStyle     =   1  'Fixed Single
  74.       Caption         =   "GridLblTitles"
  75.       Height          =   255
  76.       Index           =   7
  77.       Left            =   1200
  78.       TabIndex        =   8
  79.       Top             =   1080
  80.       Width           =   1095
  81.    End
  82.    Begin Label GridLblTitles 
  83.       Alignment       =   2  'Center
  84.       BackColor       =   &H00C0C0C0&
  85.       BorderStyle     =   1  'Fixed Single
  86.       Caption         =   "GridLblTitles"
  87.       Height          =   255
  88.       Index           =   6
  89.       Left            =   120
  90.       TabIndex        =   7
  91.       Top             =   1080
  92.       Width           =   1095
  93.    End
  94.    Begin Label GridLblTitles 
  95.       Alignment       =   2  'Center
  96.       BackColor       =   &H00C0C0C0&
  97.       BorderStyle     =   1  'Fixed Single
  98.       Caption         =   "GridLblTitles"
  99.       Height          =   255
  100.       Index           =   5
  101.       Left            =   5520
  102.       TabIndex        =   6
  103.       Top             =   720
  104.       Width           =   1095
  105.    End
  106.    Begin Label GridLblTitles 
  107.       Alignment       =   2  'Center
  108.       BackColor       =   &H00C0C0C0&
  109.       BorderStyle     =   1  'Fixed Single
  110.       Caption         =   "GridLblTitles"
  111.       Height          =   255
  112.       Index           =   4
  113.       Left            =   4440
  114.       TabIndex        =   5
  115.       Top             =   720
  116.       Width           =   1095
  117.    End
  118.    Begin Label GridLblTitles 
  119.       Alignment       =   2  'Center
  120.       BackColor       =   &H00C0C0C0&
  121.       BorderStyle     =   1  'Fixed Single
  122.       Caption         =   "GridLblTitles"
  123.       Height          =   255
  124.       Index           =   3
  125.       Left            =   3360
  126.       TabIndex        =   4
  127.       Top             =   720
  128.       Width           =   1095
  129.    End
  130.    Begin Label GridLblTitles 
  131.       Alignment       =   2  'Center
  132.       BackColor       =   &H00C0C0C0&
  133.       BorderStyle     =   1  'Fixed Single
  134.       Caption         =   "GridLblTitles"
  135.       Height          =   255
  136.       Index           =   2
  137.       Left            =   2280
  138.       TabIndex        =   3
  139.       Top             =   720
  140.       Width           =   1095
  141.    End
  142.    Begin Label GridLblTitles 
  143.       Alignment       =   2  'Center
  144.       BackColor       =   &H00C0C0C0&
  145.       BorderStyle     =   1  'Fixed Single
  146.       Caption         =   "GridLblTitles"
  147.       Height          =   255
  148.       Index           =   1
  149.       Left            =   1200
  150.       TabIndex        =   2
  151.       Top             =   720
  152.       Width           =   1095
  153.    End
  154.    Begin Label GridLblTitles 
  155.       Alignment       =   2  'Center
  156.       BackColor       =   &H00C0C0C0&
  157.       BorderStyle     =   1  'Fixed Single
  158.       Caption         =   "GridLblTitles"
  159.       Height          =   255
  160.       Index           =   0
  161.       Left            =   120
  162.       TabIndex        =   1
  163.       Top             =   720
  164.       Width           =   375
  165.    End
  166.    Begin Menu GridMnuTitleFields 
  167.       Caption         =   "&Title Field..."
  168.       Visible         =   0   'False
  169.       Begin Menu GridMnuChange 
  170.          Caption         =   "&Change Columns"
  171.       End
  172.       Begin Menu GridMnuFit 
  173.          Caption         =   "&Best Fit ColumnsTo Form"
  174.       End
  175.       Begin Menu GridMnuSort 
  176.          Caption         =   "&Sort Column"
  177.       End
  178.    End
  179. ': VB-GRID.FRM
  180. '-    Simulates a GRID.VBX
  181. '     Requires
  182. '        2_GROUPS.FRM
  183. '        2_GROUPS.BAS
  184. '        WIN.BAS
  185. '        INI_FILE.BAS
  186. ' Copyright 1994, AA-Software International
  187. '     Distributed for non-commercial educational use only.
  188. '     For other use contact:
  189. '        AA-Software International
  190. '        12 ter Domaine Du Bois Joli
  191. '        06330 Roquefort-Les-Pins, France
  192. '        Tel: (+33) 93.77.50.47
  193. '        Fax: (+33) 93.77.19.78
  194. '        Internet: cswilly@acm.org
  195. '        CompuServe: 100343,2570
  196. Option Explicit
  197. ' Programmer provided data
  198. Dim MyData() As testRecord          'Records to display
  199. Dim MyDataIdx() As Integer          'Index
  200. Dim MyDataNb As Integer             'Nb of records in MyData. -1 indicates empty
  201. Dim MyInfoRow_i As Integer         'Used to step through data
  202. Const MyIniFileName = "SoftGrid.ini"
  203. Const MyIniSectionPrefix = "SoftGrid"
  204. ' SoftGrid Data
  205. Const GridLblTitlesNb = 12             'Maximum nb of fields the form can handel
  206. Dim GridFieldsNb As Integer            'Nb of all fields that can be displayed on from
  207. Dim GridFieldNames_s() As String       'List of all field names that can be displayed on form
  208. Dim GridDispFieldsNb As Integer           'Nb of fields the user has selected to be displayed on form
  209. Dim GridDispIdx() As Integer              'Index to fields to be displaied (indexes into GridFieldNames_s() and pMyInfo)
  210. Dim GridTitleLefts() As Integer       'Left positions of grid title lables
  211. Dim GridLeft As Integer               'Starting left postion of grid
  212. Dim GridMinimumFieldWidth As Integer  'Minimum width of any field
  213. Dim GridWidth As Integer              'Current total width of grid
  214. Dim GridBottom As Integer              'Distance from bottom of form
  215. 'Used to manage user resize the width of a field
  216. Dim GridFieldIndex As Integer
  217. Dim GridMouseLeft_b As Integer
  218. Dim GridMouseRight_b As Integer
  219. Dim GridPreviousMouse_i As Integer
  220. Const GridClickWidth = 80
  221. Sub Form_Load ()
  222.    If Not myFields_Init_b() Then
  223.       Unload Me
  224.    End If
  225.    ' Initalizd Grid
  226.    GridInit
  227. End Sub
  228. Sub Form_Resize ()
  229.    GridResize
  230. End Sub
  231. ' =================== SoftGrid Starts Here ==================
  232. Function GridFitText (ByVal width_i As Integer, ByVal text_s As String) As String
  233.    width_i = width_i / 1.1
  234.    Do While Me.TextWidth(text_s) >= width_i
  235.       text_s = Left$(text_s, Len(text_s) - 1)
  236.    Loop
  237.    GridFitText = text_s
  238. End Function
  239. Sub GridIniGet ()
  240.    IniSetFileName MyIniFileName
  241.    IniSetAppName MyIniSectionPrefix & "DisplayFields"
  242.    GridDispFieldsNb = IniGetInteger("GridDispFieldsNb", -1)
  243.    If GridDispFieldsNb = -1 Then Exit Sub
  244.       
  245.    ReDim GridDispIdx(GridDispFieldsNb - 1)
  246.    Dim dispFieldKtr As Integer
  247.    For dispFieldKtr = 0 To GridDispFieldsNb - 1
  248.       GridDispIdx(dispFieldKtr) = IniGetInteger("dispField_" & Format$(dispFieldKtr), dispFieldKtr)
  249.    Next dispFieldKtr
  250.    ReDim GridTitleLefts(GridDispFieldsNb)
  251.    Dim titleLeftsKtr As Integer
  252.    For titleLeftsKtr = 0 To GridDispFieldsNb
  253.       GridTitleLefts(titleLeftsKtr) = IniGetInteger("fieldLeft_" & Format$(titleLeftsKtr), titleLeftsKtr * 120)
  254.    Next titleLeftsKtr
  255. End Sub
  256. Sub GridIniPut ()
  257.    IniSetFileName MyIniFileName
  258.    IniSetAppName MyIniSectionPrefix & "DisplayFields"
  259.    IniPutInteger "GridDispFieldsNb", GridDispFieldsNb
  260.    If GridDispFieldsNb = -1 Then Exit Sub
  261.       
  262.    Dim dispFieldKtr As Integer
  263.    For dispFieldKtr = 0 To GridDispFieldsNb - 1
  264.       IniPutInteger "dispField_" & Format$(dispFieldKtr), GridDispIdx(dispFieldKtr)
  265.    Next dispFieldKtr
  266.    Dim titleLeftsKtr As Integer
  267.    For titleLeftsKtr = 0 To GridDispFieldsNb
  268.       IniPutInteger "fieldLeft_" & Format$(titleLeftsKtr), GridTitleLefts(titleLeftsKtr)
  269.    Next titleLeftsKtr
  270. End Sub
  271. Sub GridInit ()
  272.    'Create initial list of fields to be displayed
  273.    myFields_GetFieldNames GridFieldNames_s()
  274.    GridFieldsNb = UBound(GridFieldNames_s) + 1
  275.    GridIniGet
  276.    If GridDispFieldsNb = -1 Then
  277.       If GridFieldsNb >= 2 Then
  278.      GridDispFieldsNb = 2
  279.       Else
  280.      GridDispFieldsNb = 1
  281.       End If
  282.       ReDim GridDispIdx(GridDispFieldsNb - 1)
  283.       Dim i As Integer
  284.       For i = 0 To GridDispFieldsNb - 1
  285.      GridDispIdx(i) = i
  286.       Next i
  287.       'Calc placement of titles
  288.       GridSetTitleLefts GridTitleLefts(), GridDispFieldsNb
  289.    End If
  290.    ' Hide grid titles to keep from flashing
  291.    Dim GridLblTitlesKtr As Integer
  292.    For GridLblTitlesKtr = 0 To GridLblTitlesNb - 1
  293.             
  294.       GridLblTitles(GridLblTitlesKtr).Visible = False
  295.    Next GridLblTitlesKtr
  296. End Sub
  297. Sub GridLblTitles_DblClick (index As Integer)
  298.    Dim GridPreviousMouse_i As Integer
  299.    GridPreviousMouse_i = MousePointer
  300.    MousePointer = 11
  301.    myFields_Open
  302.    Dim fieldLargest_s As String
  303.    Dim fieldLen As Integer
  304.    Dim fieldLenMax As Integer
  305.    fieldLenMax = 0
  306.    Dim rowKtr As Integer
  307.    rowKtr = 0
  308.    Do Until myFields_EOF()
  309.       fieldLen = Len(myFields_GetField_s(GridDispIdx(index)))
  310.       If fieldLen > fieldLenMax Then
  311.      fieldLenMax = fieldLen
  312.      fieldLargest_s = myFields_GetField_s(GridDispIdx(index))
  313.       End If
  314.       
  315.       myFields_GetNextField
  316.       rowKtr = rowKtr + 1
  317.    Loop
  318.    GridLst.Refresh
  319.    Dim newWidth As Integer
  320.    newWidth = Me.TextWidth(fieldLargest_s) * 1.2
  321.    GridSetNewWidth newWidth, index
  322.    GridIniPut
  323.    Form_Resize
  324.    MousePointer = GridPreviousMouse_i
  325. End Sub
  326. Sub GridLblTitles_MouseDown (index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  327.    Const LEFT_BUTTON = 1
  328.    Const RIGHT_BUTTON = 2
  329.    Const MIDDLE_BUTTON = 4
  330.    Const SHIFT_MASK = 1
  331.    Const CTRL_MASK = 2
  332.    Const ALT_MASK = 4
  333.    If Button = LEFT_BUTTON Then
  334.       GridMouseLeft_b = True
  335.    ElseIf Button = RIGHT_BUTTON Then
  336.       GridFieldIndex = index
  337.       GridMouseRight_b = True
  338.       Me.PopupMenu GridMnuTitleFields, 0, x, y
  339.    End If
  340. End Sub
  341. Sub GridLblTitles_MouseMove (index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  342.    If GridMouseRight_b Then Exit Sub
  343.    Dim distanceFromSeparator As Integer
  344.    distanceFromSeparator = GridLblTitles(index).Width - x
  345.    If distanceFromSeparator < GridClickWidth And distanceFromSeparator >= 0 And y > 15 And GridLblTitles(index).Height - y > 15 Then
  346.       If MousePointer <> 9 Then
  347.      GridPreviousMouse_i = MousePointer
  348.      MousePointer = 9
  349.       End If
  350.       If GridMouseLeft_b Then
  351.      If x < GridMinimumFieldWidth Then x = GridMinimumFieldWidth
  352.      GridLblTitles(index).Width = x
  353.      GridLblTitles(index).ZOrder 0
  354.      GridLblTitles(index).Refresh
  355.       End If
  356.    Else
  357.       If GridMouseLeft_b Then
  358.      If x < GridMinimumFieldWidth Then x = GridMinimumFieldWidth
  359.      GridLblTitles(index).Width = x
  360.      GridLblTitles(index).ZOrder 0
  361.      GridLblTitles(index).Refresh
  362.       Else
  363.      MousePointer = GridPreviousMouse_i
  364.       End If
  365.    End If
  366.       
  367. End Sub
  368. Sub GridLblTitles_MouseUp (index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  369.    If GridMouseRight_b Then
  370.       GridMouseRight_b = False
  371.       Exit Sub
  372.    End If
  373.    If GridMouseLeft_b Then
  374.       GridMouseLeft_b = False
  375.       MousePointer = GridPreviousMouse_i
  376.       Dim distanceFromSeparator As Integer
  377.       distanceFromSeparator = GridLblTitles(index).Width - x
  378.       If distanceFromSeparator < GridClickWidth And distanceFromSeparator >= 0 Then
  379.       
  380.      Dim newWidth As Integer
  381.      If x > GridMinimumFieldWidth Then
  382.         newWidth = x
  383.      Else
  384.         Beep
  385.         newWidth = GridMinimumFieldWidth
  386.      End If
  387.      GridSetNewWidth newWidth, index
  388.      GridIniPut
  389.      Form_Resize
  390.       End If
  391.    End If
  392. End Sub
  393. Function GridListCount () As Integer
  394.    GridListCount = GridLst.ListCount
  395. End Function
  396. Sub GridLst_Click ()
  397.    myFields_GridClick GridLst.ListIndex
  398. End Sub
  399. Sub GridLst_DblClick ()
  400.    myFields_GridDblClick GridLst.ListIndex
  401. End Sub
  402. Sub GridMnuChange_Click ()
  403.    tgp_initialize "Grid Headings", "Headings Not To Dispaly", "Headings To Display"
  404.    tgp_SetLeftListSorted True       'Allows easy selection by user
  405.    tgp_SetRightListSorted False     'Allows insertion by user
  406.    Dim allPosibleFieldsKtr As Integer
  407.    For allPosibleFieldsKtr = 0 To UBound(GridFieldNames_s)
  408.       Dim fieldToDisplayKtr As Integer
  409.       For fieldToDisplayKtr = 0 To UBound(GridDispIdx)
  410.      If GridDispIdx(fieldToDisplayKtr) = allPosibleFieldsKtr Then Exit For
  411.       Next fieldToDisplayKtr
  412.       If fieldToDisplayKtr <= UBound(GridDispIdx) Then
  413.      tgp_addRightSide GridFieldNames_s(allPosibleFieldsKtr)
  414.       Else
  415.      tgp_addLeftSide GridFieldNames_s(allPosibleFieldsKtr)
  416.       End If
  417.    Next allPosibleFieldsKtr
  418.    If tgp_ShowForm_s() = "OK" Then
  419.       GridDispFieldsNb = tpg_RightListCount_i()
  420.       ReDim GridDispIdx(GridDispFieldsNb - 1)
  421.       For fieldToDisplayKtr = 0 To UBound(GridDispIdx)
  422.      Dim nextFieldName As String
  423.      nextFieldName = tgp_RightList_s(fieldToDisplayKtr)
  424.      For allPosibleFieldsKtr = 0 To UBound(GridFieldNames_s)
  425.         If GridFieldNames_s(allPosibleFieldsKtr) = nextFieldName Then Exit For
  426.      Next allPosibleFieldsKtr
  427.      If allPosibleFieldsKtr <= UBound(GridFieldNames_s) Then
  428.         GridDispIdx(fieldToDisplayKtr) = allPosibleFieldsKtr
  429.      End If
  430.       Next fieldToDisplayKtr
  431.       GridSetTitleLefts GridTitleLefts(), GridDispFieldsNb
  432.       
  433.       GridIniPut
  434.       Form_Resize
  435.    End If
  436. End Sub
  437. Sub GridMnuFit_Click ()
  438.    Dim gridTitleLeft  As Integer
  439.    gridTitleLeft = GridLeft
  440.    GridWidth = Me.ScaleWidth - GridLeft * 2
  441.    Dim gridTitleWidth  As Integer
  442.    gridTitleWidth = GridWidth \ GridDispFieldsNb
  443.    If gridTitleWidth < GridMinimumFieldWidth Then gridTitleWidth = GridMinimumFieldWidth
  444.    Dim GridLblTitlesKtr As Integer
  445.    GridLblTitlesKtr = 0
  446.    Do While GridLblTitlesKtr <= GridDispFieldsNb
  447.       GridTitleLefts(GridLblTitlesKtr) = gridTitleLeft
  448.       gridTitleLeft = gridTitleLeft + gridTitleWidth
  449.       GridLblTitlesKtr = GridLblTitlesKtr + 1
  450.    Loop
  451.    GridIniPut
  452.    Form_Resize
  453. End Sub
  454. Sub GridMnuSort_Click ()
  455.    mySortField GridDispIdx(GridFieldIndex)
  456.    Form_Resize
  457. End Sub
  458. 'GridResetTitleLefts
  459. Sub GridResize ()
  460.    Dim GridPreviousMouse_i As Integer
  461.    GridPreviousMouse_i = MousePointer
  462.    MousePointer = 11
  463.    ' Determin position params
  464.    Dim gridTitleTop  As Integer
  465.    gridTitleTop = GridLblTitles(0).Top
  466.    Dim gridTitleHeight As Integer
  467.    gridTitleHeight = GridLblTitles(0).Height
  468.    If GridLeft = 0 Then GridLeft = GridLblTitles(0).Left
  469.    If GridMinimumFieldWidth = 0 Then GridMinimumFieldWidth = GridLblTitles(0).Width
  470.    If GridBottom = 0 Then GridBottom = Me.ScaleHeight - (GridLst.Top + GridLst.Height)
  471.    GridWidth = Me.ScaleWidth - GridLeft * 2
  472.    ' Position GridLblTitles
  473.    Dim lastGridTitleDisplayed As Integer
  474.    Dim GridLblTitlesKtr As Integer
  475.    GridLblTitlesKtr = 0
  476.             
  477.    ' Step thru each grid lable
  478.    Do While GridLblTitlesKtr < GridLblTitlesNb
  479.       ' Make lable visiable
  480.       If (GridLblTitlesKtr < GridDispFieldsNb) Then
  481.      'Ensure lable is not off the form
  482.      If (GridTitleLefts(GridLblTitlesKtr + 1) - GridLeft <= GridWidth) Then
  483.         GridLblTitles(GridLblTitlesKtr).Top = gridTitleTop
  484.         GridLblTitles(GridLblTitlesKtr).Left = GridTitleLefts(GridLblTitlesKtr)
  485.         GridLblTitles(GridLblTitlesKtr).Width = GridTitleLefts(GridLblTitlesKtr + 1) - GridTitleLefts(GridLblTitlesKtr)
  486.         GridLblTitles(GridLblTitlesKtr).Caption = GridFieldNames_s(GridDispIdx(GridLblTitlesKtr))
  487.         GridLblTitles(GridLblTitlesKtr).Visible = True
  488.         lastGridTitleDisplayed = GridLblTitlesKtr
  489.      Else
  490.         GridLblTitles(GridLblTitlesKtr).Visible = False
  491.      End If
  492.       Else
  493.      GridLblTitles(GridLblTitlesKtr).Visible = False
  494.       End If
  495.       GridLblTitlesKtr = GridLblTitlesKtr + 1
  496.    Loop
  497.    ' Update the grid itself
  498.    ' Position GridLst
  499.    GridLst.Top = gridTitleTop + gridTitleHeight
  500.    GridLst.Left = GridLeft
  501.    GridLst.Width = GridLblTitles(lastGridTitleDisplayed).Left - GridLeft + GridLblTitles(lastGridTitleDisplayed).Width
  502.    Dim newGridHeight As Integer
  503.    newGridHeight = Me.ScaleHeight - GridBottom - GridLst.Top
  504.    If newGridHeight < 120 Then newGridHeight = 120
  505.    GridLst.Height = newGridHeight
  506.    ' Set list box tabs to match grid headings
  507.    ReDim GridLstTabStops(GridDispFieldsNb - 2) As Integer
  508.    Dim i As Integer
  509.    For i = 1 To GridDispFieldsNb - 1
  510.       GridLstTabStops(i - 1) = (GridLblTitles(i).Left - GridLeft) / Me.TextWidth("H") * 1.44
  511.    Next i
  512.    win_ListBoxSetTabs GridLst, GridLstTabStops()
  513.    ' Put data into grid
  514.    GridLst.Clear
  515.    ReDim listGridInfo(GridDispFieldsNb - 1) As String
  516.    myFields_Open
  517.    Dim rowKtr As Integer
  518.    rowKtr = 0
  519.    Do Until myFields_EOF()
  520.       For i = 0 To GridDispFieldsNb - 1
  521.      listGridInfo(i) = GridFitText(GridLblTitles(i).Width, myFields_GetField_s(GridDispIdx(i)))
  522.       Next i
  523.       myFields_GetNextField
  524.       win_ListBoxAddTabItems GridLst, listGridInfo()
  525.       rowKtr = rowKtr + 1
  526.    Loop
  527.    GridLst.Refresh
  528.    MousePointer = GridPreviousMouse_i
  529. End Sub
  530. Function GridSelected (ByVal row_i As Integer) As Integer
  531.    GridSelected = GridLst.Selected(row_i)
  532. End Function
  533. Sub GridSetNewWidth (newWidth As Integer, index As Integer)
  534.      Dim changeInWidth As Integer
  535.      changeInWidth = newWidth - (GridTitleLefts(index + 1) - GridTitleLefts(index))
  536.       
  537.      'make sure we don't go past end of form
  538.      If GridTitleLefts(index + 1) + changeInWidth > GridWidth Then
  539.         changeInWidth = GridWidth - GridTitleLefts(index + 1)
  540.         Beep
  541.         Beep
  542.      End If
  543.      'change all following positions
  544.      Dim i As Integer
  545.         For i = index + 1 To UBound(GridTitleLefts)
  546.            GridTitleLefts(i) = GridTitleLefts(i) + changeInWidth
  547.      Next i
  548. End Sub
  549. Sub GridSetTitleLefts (GridTitleLefts() As Integer, ByVal GridDispFieldsNb As Integer)
  550.    ReDim GridTitleLefts(GridDispFieldsNb)
  551.    If GridLeft = 0 Then GridLeft = GridLblTitles(0).Left
  552.    If GridMinimumFieldWidth = 0 Then GridMinimumFieldWidth = GridLblTitles(0).Width
  553.    Dim gridTitleLeft  As Integer
  554.    gridTitleLeft = GridLeft
  555.    GridWidth = Me.ScaleWidth - GridLeft * 2
  556.    Dim gridTitleWidth  As Integer
  557.    gridTitleWidth = GridWidth \ GridDispFieldsNb
  558.    If gridTitleWidth < GridMinimumFieldWidth Then gridTitleWidth = GridMinimumFieldWidth
  559.    Dim GridLblTitlesKtr As Integer
  560.    GridLblTitlesKtr = 0
  561.    Do While GridLblTitlesKtr <= GridDispFieldsNb
  562.       GridTitleLefts(GridLblTitlesKtr) = gridTitleLeft
  563.       gridTitleLeft = gridTitleLeft + gridTitleWidth
  564.       GridLblTitlesKtr = GridLblTitlesKtr + 1
  565.    Loop
  566. End Sub
  567. ' =================== SoftGrid Ends Here ==================
  568. Function myFields_EOF () As Integer
  569.    If MyDataNb = -1 Then
  570.       myFields_EOF = True
  571.    Else
  572.       myFields_EOF = MyInfoRow_i >= MyDataNb
  573.    End If
  574. End Function
  575. Function myFields_GetField_s (ByVal field_i As Integer) As String
  576.    Dim index As Integer
  577.    index = MyDataIdx(MyInfoRow_i)
  578.    If Not myFields_EOF() And field_i < GridFieldsNb Then
  579.       Select Case field_i
  580.       Case 0
  581.      myFields_GetField_s = MyData(index).Zero
  582.       Case 1
  583.      myFields_GetField_s = MyData(index).One
  584.       Case 2
  585.      myFields_GetField_s = MyData(index).Two
  586.       Case 3
  587.      myFields_GetField_s = MyData(index).Three
  588.       Case 4
  589.      myFields_GetField_s = MyData(index).Four
  590.       Case 5
  591.      myFields_GetField_s = MyData(index).Five
  592.       Case 6
  593.      myFields_GetField_s = MyData(index).Six
  594.       Case 7
  595.      myFields_GetField_s = MyData(index).Seven
  596.       Case 8
  597.      myFields_GetField_s = MyData(index).Eight
  598.       Case 9
  599.      myFields_GetField_s = MyData(index).Nine
  600.       Case 10
  601.      myFields_GetField_s = MyData(index).Ten
  602.       End Select
  603.       Else
  604.       myFields_GetField_s = ""
  605.    End If
  606. End Function
  607. Sub myFields_GetFieldNames (filedNames_s() As String)
  608.    ReDim filedNames_s(10)
  609.    filedNames_s(0) = "Zero"
  610.    filedNames_s(1) = "One"
  611.    filedNames_s(2) = "Two"
  612.    filedNames_s(3) = "Three"
  613.    filedNames_s(4) = "Four"
  614.    filedNames_s(5) = "Five"
  615.    filedNames_s(6) = "Six"
  616.    filedNames_s(7) = "Seven"
  617.    filedNames_s(8) = "Eight"
  618.    filedNames_s(9) = "Nine"
  619.    filedNames_s(10) = "Ten"
  620. End Sub
  621. Sub myFields_GetNextField ()
  622.    MyInfoRow_i = MyInfoRow_i + 1
  623. End Sub
  624. Sub myFields_GridClick (ByVal index As Integer)
  625.    Beep
  626. End Sub
  627. Sub myFields_GridDblClick (ByVal index As Integer)
  628.    Beep
  629. End Sub
  630. Function myFields_Init_b () As Integer
  631.    'Set Field values
  632.    MyDataNb = 30
  633.    ReDim MyData(MyDataNb - 1)
  634.    ReDim MyDataIdx(MyDataNb - 1)
  635.    Dim rowKtr As Integer
  636.    For rowKtr = 0 To MyDataNb - 1
  637.       MyDataIdx(rowKtr) = rowKtr
  638.       MyData(rowKtr).Zero = Format$(Rnd * 100) & "-zero"
  639.       MyData(rowKtr).One = Format$(Rnd * 100) & "-one"
  640.       MyData(rowKtr).Two = Format$(Rnd * 100) & "-two"
  641.       MyData(rowKtr).Three = Format$(Rnd * 100) & "-three"
  642.       MyData(rowKtr).Four = Format$(Rnd * 100) & "-four"
  643.       MyData(rowKtr).Five = Format$(Rnd * 100) & "-five"
  644.       MyData(rowKtr).Six = Format$(Rnd * 100) & "-six"
  645.       MyData(rowKtr).Seven = Format$(Rnd * 100) & "-seven"
  646.       MyData(rowKtr).Eight = Format$(Rnd * 100) & "-eight"
  647.       MyData(rowKtr).Nine = Format$(Rnd * 100) & "-nine"
  648.       MyData(rowKtr).Ten = Format$(Rnd * 100) & "-ten"
  649.    Next rowKtr
  650.    myFields_Init_b = True
  651. End Function
  652. Sub myFields_Open ()
  653.    If MyDataNb <> -1 Then
  654.       MyInfoRow_i = LBound(MyData)
  655.    End If
  656. End Sub
  657. Sub mySortField (ByVal fieldToSortOn As Integer)
  658.       
  659.       '
  660.       ' To perform this sort, you need the Registered version of AAVBSORT.DLL
  661.       '
  662.       SortIdxTextRecord MyData(), testRecord_ut, MyDataIdx(), fieldToSortOn + 1
  663.       ' The Shareware version AAVBSORT.DLL is available on:
  664.       '     CompuServe Forum: MSBASIC
  665.       '     Lib:  17
  666.       '     File: AASORT.ZIO
  667.       '
  668.       ' The file ORDER.TXT contains information on how to acquire the
  669.       ' registered version of AAVBSORT.DLL. You can also contact:
  670.       '
  671.       '     C.Scott Willy
  672.       '     Commercial Director
  673.       '     AA-Software International
  674.       '     12 ter Domaine Du Bois Joli
  675.       '     6330 Roquefort -Les - Pins, France
  676.       '
  677.       '     Tel: (+33) 93.77.50.47
  678.       '     Fax: (+33) 93.77.19.78
  679.       '     Internet: cswilly@acm.org
  680.       '     CompuServe: 100343,2570
  681.       
  682. End Sub
  683.